﻿using System;
using System.Configuration;
using System.Web;
using Moxiecode.TinyMCE.Settings;

namespace Moxiecode.TinyMCE.Configuration
{
    #region TinyConfigSection
    public class TinyConfigSection : ConfigurationSection
    {
        public TinyConfigSection()
        {
        }

        [ConfigurationProperty("installPath", DefaultValue = "~/js/tiny_mce/")]
        public string InstallPath
        {
            get { return (string)this["installPath"]; }
            set { this["installPath"] = value; }
        }

        [ConfigurationProperty("fileName", DefaultValue = "tiny_mce")]
        public string FileName
        {
            get { return (string)this["fileName"]; }
            set { this["fileName"] = value; }
        }

        [ConfigurationProperty("mode", DefaultValue = Mode.TextBoxes)]
        public Mode Mode
        {
            get { return (Mode)this["mode"]; }
            set { this["mode"] = value; }
        }

        [ConfigurationProperty("suffix", DefaultValue = "")]
        public string Suffix
        {
            get { return (string)this["suffix"]; }
            set { this["suffix"] = value; }
        }

        [ConfigurationProperty("globalSettings")]
        public KeyValueConfigurationCollection GlogalSettings
        {
            get { return (KeyValueConfigurationCollection)this["globalSettings"]; }
            set { this["globalSettings"] = value; }
        }

        [ConfigurationProperty("gzipCompressor")]
        public GzipTinyConfigElement GzipCompressor
        {
            get { return (GzipTinyConfigElement)this["gzipCompressor"]; }
            set { this["gzipCompressor"] = value; }
        }

    }
    #endregion

    #region GzipTinyConfigElement
    public class GzipTinyConfigElement : ConfigurationElement
    {
        public GzipTinyConfigElement()
        {
        }

        [ConfigurationProperty("enabled", DefaultValue = false)]
        public bool Enabled
        {
            get { return (bool)this["enabled"]; }
            set { this["enabled"] = value; }
        }

        [ConfigurationProperty("noCompression", DefaultValue = false)]
        public bool NoCompression
        {
            get { return (bool)this["noCompression"]; }
            set { this["noCompression"] = value; }
        }

        [ConfigurationProperty("diskCache", DefaultValue = false)]
        public bool DiskCache
        {
            get { return (bool)this["diskCache"]; }
            set { this["diskCache"] = value; }
        }

        [ConfigurationProperty("cachePath", DefaultValue = "c:\\temp")]
        public string CachePath
        {
            get { return (string)this["cachePath"]; }
            set { this["cachePath"] = value; }
        }

        [ConfigurationProperty("expiresOffset", DefaultValue = 10L)]
        public long ExpiresOffset
        {
            get { return (long)this["expiresOffset"]; }
            set { this["expiresOffset"] = value; }
        }
    }
    #endregion
}
